package com.atguigu.tingshu.order.interceptor.impl;

import com.alibaba.fastjson.JSON;
import com.atguigu.tingshu.common.constant.SystemConstant;
import com.atguigu.tingshu.order.helper.SignHelper;
import com.atguigu.tingshu.order.interceptor.OrderHandlerInterceptor;
import com.atguigu.tingshu.vo.order.OrderInfoVo;
import io.swagger.v3.core.util.Json;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 数据合法性校验任务类 第一个执行
 * @author Petrichor
 */
@Service
@Slf4j
public class ValidDataOrderHandlerInterceptor implements OrderHandlerInterceptor {

    /**
     * @description: 数据合法性校验任务
     * @author Petrichor
     * @date 2024/1/7 23:22
     * @param orderInfoVo 订单信息
     * @return orderInfoVo 订单信息
     **/
    @Override
    public OrderInfoVo sbumitOrderRequestProcess(OrderInfoVo orderInfoVo) {


        Map<String , Object> map = JSON.parseObject(JSON.toJSONString(orderInfoVo), Map.class);
        map.put("payWay" , SystemConstant.ORDER_PAY_WAY_WEIXIN) ;
        // 合法性校验
        SignHelper.checkSign(map);
        return orderInfoVo;
    }

    @Override
    public int sort() {
        return 1;
    }

}